﻿using System.Text.RegularExpressions;
using System.Xml.Linq;

namespace HelpersDotNet.Extensions
{
    public static partial class Extensions
    {
        /// <summary>
        /// Check if the string is a valid Email
        /// </summary>
        /// <param name="s">String to check.</param>
        /// <returns>Returns true if it is a valid email address.</returns>
        public static bool IsValidEmailAddress(this string s)
        {
            Regex regex = new Regex(@"^([a-zA-Z0-9_'+*$%\^&!\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9:]{2,4})+$");
            return regex.IsMatch(s);
        }

        public static XElement ToXElement(this string s)
        {
            return XElement.Parse(s);
        }

        public static XElement ToXElement(this string s, LoadOptions loadOptions)
        {
            return XElement.Parse(s, loadOptions);
        }
    }
}
